﻿using System;
using System.Linq;
using System.Web.UI.WebControls;
using Models;
using System.Data;


public partial class PhotoList : AdminBase
{

    private DataTable dc = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        grdbind();
    }

    public void grdbind()
    {
        using (Entities bll = new Entities())
        {
            //var Bpl = bll.L_Tags;
            //PagedDataSource pds = new PagedDataSource();
            //pds.DataSource = Bpl.ToList();  //这里好像一定要Tolist();不然会有点错误；
            // pds.AllowPaging = true;            
            this.rptList.DataSource = bll.Photo_Item.ToList();
            this.rptList.DataBind();
        }
    }
    protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(((Label)e.Item.FindControl("lb_id")).Text);
        Entities bll = new Entities();
        Photo_Item model = bll.Photo_Item.First(p => p.PID == id);
        switch (e.CommandName.ToLower())
        {
            case "del":
                bll.Photo_Item.Remove(model);
                break;
        }
        bll.SaveChanges();
        grdbind();

    }

}

